package com.example.studentcompetitionplatform.controller;

import com.example.studentcompetitionplatform.entity.CompetitionArchives;
import com.example.studentcompetitionplatform.entity.Competitions;
import com.example.studentcompetitionplatform.service.IJingSaiService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.Map;

@RestController
@RequestMapping("/jingsai")
public class JingSaiController {
    @Resource
    private IJingSaiService jingSaiService;
    //新增
    @PostMapping("/register")
    public Integer register(@RequestBody Competitions competitions){
        jingSaiService.insertC(competitions);
        return 1;
    }
    //删除
    @PostMapping("/del")
    public Integer delete(@RequestBody Competitions competitions){
        jingSaiService.deleteC(competitions);
        return 1;
    }
    //编辑
    @PostMapping("/edit")
    public Integer edit(@RequestBody Competitions competitions){
        jingSaiService.editC(competitions);
        return 1;
    }
    //分页数据查询
    @GetMapping("/page")
    public Map<String, Object> findPage(@RequestParam(value = "pageNum") Integer pageNum,
                                        @RequestParam(value = "pageSize") Integer pageSize,
                                        @RequestParam(value = "competitionId",required = false) Integer competitionId
                                        ) {
        return jingSaiService.page(pageNum,pageSize,competitionId);
    }
}
